package com.heima.article.controller;

import com.heima.apis.article.ApArticleControllerApi;
import com.heima.article.service.ApArticleService;
import com.heima.model.article.pojos.ApArticle;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/v1/article")
@Log4j2
public class ApArticleController implements ApArticleControllerApi {
    @Autowired
    ApArticleService apArticleService;
    @Override
    @PostMapping("save")
    public ApArticle saveArticle(@RequestBody ApArticle apArticle) {
         apArticleService.save(apArticle);
         return apArticle;
    }

    @Override
    @GetMapping("{id}")
    public Map findArticle(@PathVariable Long id) {
        return apArticleService.findArticle(id);
    }
}
